/**
 * Created by ritamashin on 2017/11/2.
 */
import React, {Component} from 'react'
import {StyleSheet, Text,View} from 'react-native'
import * as Animatable from 'react-native-animatable'
import {bindActionCreators} from 'redux'
import {connect} from 'react-redux'
import {COLOR,SCREEN_HEIGHT,SCREEN_WIDTH} from '../../config'


function ErrorFlash({error, containerStyle}) {
    error = error.flash
    if (!error){
        return null
    }

    return (
        <View style={[styles.container, containerStyle]}>
            <Animatable.View
                animation = 'fadeIn'
            >
                <Text style={styles.error}>{error}</Text>
            </Animatable.View>

        </View>

    )
}

const styles = StyleSheet.create({
    container : {
        flex: 1,
        alignItems : 'center',
        justifyContent : 'center'
    },
    error :{
        fontSize : 12,
        color: COLOR.mainTextColor
    }
})


function mapStateToProps(state) {
    let {error} = state;
    return {
        error
    }
}

function mapDispatchToProps(dispatch) {
    return bindActionCreators({}, dispatch)
}

export default connect(mapStateToProps, mapDispatchToProps)(ErrorFlash);